Repository navigation
fix(mcp): the refusal-reasons relay withholds only the security gate's own refusal - #37537
Conversation
…s own refusal Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L6bhgVUz5oS8fMgmncxU96
📓 Docs Drift Check3 anchor(s) derived from 1 changed package(s); no hand-written page names any of them, so this run has nothing to list — not a clean bill of health. This check sees only pages that NAME a derived anchor: one that documents this change in prose, or enumerates it in an authoring dialect, names none and stays invisible to it on every run. What this run could not see
Coarse fallback — 12 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin c32e51ce498f8f5764ae3d1b772aabc0b26064d0 && git checkout c32e51ce498f8f5764ae3d1b772aabc0b26064d0
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 98cc0e45b8e3c0c7fe5a9da4ff157ede05768fd9 4682eb84568febbca9a4db4e2ce6b3347345d6c3 && git checkout -B drift-repro 98cc0e45b8e3c0c7fe5a9da4ff157ede05768fd9 && git merge --no-ff 4682eb84568febbca9a4db4e2ce6b3347345d6c3
node scripts/docs-audit/affected-docs.mjs --json 98cc0e45b8e3c0c7fe5a9da4ff157ede05768fd9 |
|
repo:objectstack#2 · os-sales · session_01L6bhgV6i8jfWwSXjpWJrjA 席位核对 — ACCEPT · head 4682eb8 · area s2-ai · 2026-11-26T11:54ZL1 checklist
Seat's own read of the security edge (no contract face is hit —
Deviations recorded: a local re-run of the two-minute check from this seat's older checkout is NOT MEASURED (the tree predates the test file's harness); the CI check-runs at this head are the reading. Tier: S (not governed, 267 lines). Landing: ready + auto-merge by this stroke. Generated by Claude Code |
Requested by Sales · project thread
Fixes #37512
Clause-②: no
Metadata-protocol: none
维护者速读
What changes
packages/mcp/src/mcp-http-tools.tsonly, plus the tests and one changeset.withRefusalReasonsRelaynow withholds the relay block on a servedPERMISSION_DENIEDwith nodeclaredCode: the security gate's own refusal. A listed refusal an app's catalogue declared at403under its own code is served asPERMISSION_DENIEDwith that code indeclaredCode(the doors' demotion of an unregistered code) and now gets the block.errorResultFromThrown'sPERMISSION_DENIEDarm now passes through the same function, sorun_action/resume_runreach it too; that arm still serves nodetails(the security(mcp): run_action renders a thrown refusal's details verbatim, while the runtime dispatcher withholds a PermissionDeniedError's details (ruling on #7450): whether a raw permission refusal reaches it is unmeasured #23529 / The runtime dispatcher serialises a PermissionDeniedError'sdetailsto the client, sopositions/permissionSetsreach the browser on the/datatransport #7450 withholding is unchanged). The relay reads onlyrefusalsanduserMessage, neverdetails, so the gate'spositions/permissionSetsreach it on no path.details.refusals:mapDataError(what the/dataroutes answer with) andactionsDoorAnswerOf(what/actionsanswers with, itsuserMessageuncut, closing line included). The dispatcher's withholding arm keys onisPermissionDeniedError, which readsfalsefor that throw (scratch probe againstplugin-security's source: app-at-403false, gate-shapedtrue). So MCP serves nothing REST does not serve the same caller. MCP stays stricter than REST in two places, both left alone: the gate's own literalPERMISSION_DENIEDcarrying a list (REST/datawould attach it), anddetailsonrun_actionfor the demoted 403.run_actionandresume_run, the only renderers that reach the relay on a fault; on the record tools a declared 5xx never reaches the envelope path). The jsdoc reason is corrected: the doors do still serveuserMessageon a declared 5xx; the block is withheld because a refusal catalogue declares only a 4xx (declaredRefusalEntrySchema), so a listed throw at a 5xx is no catalogue refusal.delete_recordsper-row refusals: declared needless, with a pin. Measured: the per-row group'sreasonis NOT cut. The catalogue throws a codedSandboxErrorwhose caller sentence (innerMessage) is the same text asuserMessage(hook-refusal-catalogue.ts, both set toanswer.message), androwRefusalOfreads a coded throw's own sentence, never the door's 500-character cut. So each group already names every line whole, in order, closing line last. No relay block is added, so the grouping shape is untouched;rowRefusalOf's jsdoc says why, and a pin holds a list over 500 characters.REFUSAL_REASONS_RELAY_LEADnow readsTell the user every line below, whole and in this order, in place of userMessage:(true on both doors;/actionsnever cuts).Tests
packages/mcp/src/mcp-refusal-reasons.test.ts(the card's harness file; new top-leveldescribeblocks), 17 new cases, all through the real HTTP/mcptransport:content[0]is{ code: PERMISSION_DENIED, declaredCode, status: 403 }with nodetails,content[1]is the relay. Parity case:mapDataErrorandactionsDoorAnswerOfon the same throw servedetails.refusalsequal to the lines. Control: a gate-shaped throw (PermissionDeniedError, literal code,details.positions/permissionSets) answers one block on every tool, nodeclaredCode, and none of its details' text.run_actionandresume_runanswers one block, status 503, nodetails.query_records,aggregate_records,get_record,get_record_contextand thedelete_recordsouter catch each answer the relay,content[0]equal to the same throw without a list;query_recordswith an unknown field keepsnotRecorded/ifNotRecordedbeside the envelope and the relay after it.FLOW_FAILEDthrow that is also listed answers three blocks in order: envelope, flow sentence, relay.delete_recordsover two rows refused by a six-line list (over 500 characters): one group,reasonequal to the whole text, its lines the listed lines then the closing line; one content block.asCatalogueoption (caller sentence =userMessage, the catalogue's real shape); the MCP:一次拒绝带多条原因时,把 details.refusals 逐条转给智能体(接 #36877) #37416 cases keep their old double unchanged.Package suite, typecheck, ablations (head 4682eb8)
pnpm --filter @objectstack/mcp typecheck && pnpm --filter @objectstack/mcp exec vitest run --maxWorkers=2, under the verify lock:VERDICT command-exit 0; Test Files 86 passed (86), Tests 1557 passed (1557) (1540 on main + 17);check:test-typecheck: OK.node scripts/ablation-replace.mjs, anchorPERMISSION_DENIED && served.declaredCode === undefined)to the bare code check; blob 0754deea to 5fe5f300): 5 failed / 26 passed, the five per-tool 403 cases. Restored: blob equals HEAD,git diff HEADempty. (A first attempt with a replacement that already occurred in the file was refused by the tool before any run: counted 5 to 5; re-run with a distinct marker.)isServerFaultguard deleted; blob to fa47a2ee): 2 failed / 29 passed, the two 503 cases. Restored,git diff HEADempty./actions(thePERMISSION_DENIEDarm back tocodedErrorResult(envelope); blob to 4f91d8a8): 2 failed / 29 passed, therun_action/resume_run403 cases. Restored,git diff HEADempty.src/relatively, so no rebuild was needed for the ablations.Acceptance notes
declaredRefusalEntrySchematakes 400 to 499; the hook and action schema tests refuse 500 / 503); the arm is defence for a hand-built listed throw. S3's "keeps the cut sentence" does not hold for the catalogue's throw (see What changes); it held only for the MCP:一次拒绝带多条原因时,把 details.refusals 逐条转给智能体(接 #36877) #37416 test double, whose caller sentence is the bare code.run_action/resume_runstill serve nodetailson anyPERMISSION_DENIED, including the demoted 403, while REST/actionsserves itsdetails.refusals. The relay block now carries those lines, so nothing an agent needs is missing; wideningdetailsthere is outside this card.Security-touchingreads yes for the reviewer; no exposure found (the relay reads nodetails).Verification
Derived gates (67), on 4682eb8
node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack(3 paths vs merge base 54ea3c8): 67 derived; 66 exit 0. One NOT MEASURED:pnpm check:dual-build-cjs-loadsexit 3 (PREREQUISITE NOT MET: needs the whole workspace built; CI Build Core runs it).--ranreconciliation with exit codes recorded: 67 accounted, 66 run, 1 NOT-MEASURED (derived from the recorded exit 3), 0 UNRUN.node scripts/pm/overlap-check.mjs: clean against origin/main and feat(spec,ui): a field can be read-only by hand at the console while writes keep it (uiReadonly / uiReadonlyWhen) #37436.CI check-runs are the authority for every family.
Two-minute check:
pnpm --filter @objectstack/mcp exec vitest run --maxWorkers=2 src/mcp-refusal-reasons.test.ts. Expect 31 passed.Read first:
withRefusalReasonsRelay(the narrowed guard and its jsdoc), thePERMISSION_DENIEDarm oferrorResultFromThrown, and the parity case in the test file.🤖 Generated with Claude Code
https://claude.ai/code/session_01L6bhgVUz5oS8fMgmncxU96